global root_dir = "`1'"

include "$root_dir/code/config/config.do"

cap noi log using ${log_dir}/figure_A1_tech_fields.log, replace name(fig)

capture noi {

    *figure gets biadic patent applications and checks how many there are per technology field
    * we seperate out the assembly of the data because it uses patstat data almost directly. 
    *the dataset imported here is the finished, aggregated version for the figure
    use  ${final_dir}/fig_A1_data.dta, clear

    local plot_type "bar" 
    qui include ${code_dir}/config/figuretools.do

    colorpalette ptol, n(1) nograph
    graph hbar (sum)share, over(techn_field,label(labsize(7pt))) ytitle("Percent")
    graph export ${fig_dir}/appendix/Figure_A1_tech_fields.pdf, replace


    *eps version
    graph hbar (sum)share, over(techn_field,label(labsize(7pt))) ytitle("Percent")
    graph export ${fig_dir}/appendix/Figure_A1_tech_fields.eps, replace
}
if _rc == 0 {
    display "Execution finished successfully."
}
else {
    display "Execution finished with errors."
}

cap log close fig